package com.song.studentddb.service;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.song.studentddb.mapper.studentMapper;
import com.song.studentddb.pojo.Student;
import com.song.studentddb.vo.PageVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("studentService")
public class StudentServiceimpl extends ServiceImpl<com.song.studentddb.mapper.studentMapper, Student>implements StudentService {

    @Resource
    private studentMapper studentMapper;

    @Override
    public PageVo getPageList(Integer pageNo, Integer pageSize) {
        Page page = new Page();
        page.setCurrent(pageNo);//当前页码数
        page.setSize(pageSize); //每页显示大小
        List<Student> list = studentMapper.getUrList(page);
        page.setRecords(list);
        return PageVo.getInstance(page);
    }

    @Override
    public int delete(Integer sid) {
        return studentMapper.delete(sid);
    }

    @Override
    public int update(Student student) {

        UpdateWrapper<Student> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("sid",student.getSid());
        return studentMapper.update(student,updateWrapper);
    }
}
